/*
* ExpertController.java
* Created on  2015-4-5 下午3:35
* 版本       修改时间          作者      修改内容
* V1.0.1    2015-4-5       weixuda    初始版本
*
*/
package com.ccut.bits.expert;

import com.ccut.bits.security.service.ExpertService;
import com.ccut.bits.model.Expert;
import com.ccut.bits.page.PageResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

/**
 * 类的描述信息
 *
 * @author weixuda
 * @version 1.0.1
 */
@Controller
@RequestMapping("/expert")
public class ExpertController {

    @Autowired
    private ExpertService expertService;

    @RequestMapping("/getExpertList")
    public String getExpertList() {
        return "expert/getExpertList";
    }

    @RequestMapping("/getExpertDetail")
    public String getLiteratureDetail() {
        return "literature/getLiteratureDetail";
    }

    @RequestMapping(value = "/getExpertListDo", method = {RequestMethod.POST})
    @ResponseBody
    public PageResponse<Expert> getExpertListDo(Expert expert){
        return  new PageResponse<>(expert.getPage(),expertService.getExpertListPage(expert));
    }

    @RequestMapping("/addExpertDo")
    public String addExpertDo(){
        return "security/expert/addExpertDo";
    }

    @RequestMapping("/addExpert")
    @ResponseBody
    public void addExpert(Expert expert){
        expertService.addExpert(expert);
    }


    @RequestMapping("/editExpertDo")
    public String editExpertDo(HttpServletRequest request, @RequestParam("id") int id){
        Expert expert = expertService.getExpertById(id);
        request.setAttribute("expert", expert);
        return "security/expert/editExpertDo";
    }
}
